<?php
namespace app\fsadmin\controller;

use think\Controller;

class SystemController extends BaseController
{
    public function config()
    {
        $conf   = model("config")->getConfByKey("conf");
        $config = unserialize($conf["value"]);
        $this->assign("conf", $config);

        return $this->fetch();
    }

    public function saveconfig()
    {
        if ($this->request->isAjax()) {
            $params = $this->request->param();

            $data['value'] = serialize($params);
            $conf_m        = model("Config");
            if ($conf_m->saveConf($data, ["key" => "conf"])) {
                model("log")->saveLog(["content"=>"更新网站配置信息","datas"=> $data['value']]);
                $rs['msg']    = "更新成功";
                $rs['status'] = 200;
                ajax_return($rs);
            }
        }
    }

    public function log()
    {
        if ($this->request->isAjax()) {
            $params = $this->request->param();
            $data =  model("log")->getLogs($params);
            $rs['data']['list'] = $data['data'];
            $rs['status']       = 200;
            $rs['pages'] = $data['last_page'];
            $rs['total'] = $data['total'];
            ajax_return($rs);
        }   

        return $this->fetch(); 
    }
}
